#pragma once

#include <cstdint>
#include <vector>
#include <memory>
#include "engine/platform/texture.h"


namespace kanon
{
    class FrameBuffer
    {
    private:
        uint32_t fbo;
        std::vector<uint32_t> color_buffers;
        uint32_t rbo;
        uint32_t width;
        uint32_t height;
        
    public:
        FrameBuffer();
        bool Init(uint32_t width, uint32_t height, uint32_t num_color_buffers, bool depthstencil);
        bool Init(uint32_t width, uint32_t height, const std::shared_ptr<Texture2D>& texture);
    
        void Bind() const;
        void Bind(const std::vector<uint32_t>& buffer_indices) const;
        void Unbind() const;

        uint32_t GetColorAttachment(uint32_t index) const { return color_buffers[index]; }

        void Capture(uint32_t index, const char* filepath);
        void CaptureTexture(uint32_t texture_id, uint32_t width, uint32_t height, const char* filepath);
    };
}
